<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>游戏模块测试</title>
</head>
<body>
    <h1>游戏模块加载测试</h1>
    <div id="test-results"></div>

    <!-- 按照正确顺序加载脚本 -->
    <script src="js/utils/Vector2D.js"></script>
    <script src="js/utils/ParticleSystem.js"></script>
    <script src="js/systems/InputHandler.js"></script>
    <script src="js/buildings.js"></script>
    <script src="js/renderer.js"></script>
    <script src="js/collision.js"></script>
    <script src="js/ai.js"></script>
    <script src="js/Game.js"></script>

    <script>
        const results = document.getElementById('test-results');
        
        function test(name, condition) {
            const status = condition ? '✅' : '❌';
            results.innerHTML += `<p>${status} ${name}: ${condition ? 'OK' : 'FAILED'}</p>`;
        }
        
        // 测试各个类是否正确加载
        test('Vector2D 类', typeof Vector2D !== 'undefined');
        test('ParticleSystem 类', typeof ParticleSystem !== 'undefined');
        test('InputHandler 类', typeof InputHandler !== 'undefined');
        test('Building 类', typeof Building !== 'undefined');
        test('WoodenHouse 类', typeof WoodenHouse !== 'undefined');
        test('ConcreteHouse 类', typeof ConcreteHouse !== 'undefined');
        test('GameRenderer 类', typeof GameRenderer !== 'undefined');
        test('CollisionSystem 类', typeof CollisionSystem !== 'undefined');
        test('TankAI 类', typeof TankAI !== 'undefined');
        test('PathFinder 类', typeof PathFinder !== 'undefined');
        test('ShootingPredictor 类', typeof ShootingPredictor !== 'undefined');
        test('TacticalAnalyzer 类', typeof TacticalAnalyzer !== 'undefined');
        test('Game 类', typeof Game !== 'undefined');
        
        // 测试创建实例
        try {
            const testVector = new Vector2D(10, 20);
            test('Vector2D 实例化', testVector.x === 10 && testVector.y === 20);
        } catch (e) {
            test('Vector2D 实例化', false);
            console.error('Vector2D error:', e);
        }
        
        try {
            const testBuilding = new Building(0, 0, 50, 50);
            test('Building 实例化', testBuilding.position.x === 0);
        } catch (e) {
            test('Building 实例化', false);
            console.error('Building error:', e);
        }
        
        try {
            const canvas = document.createElement('canvas');
            const ctx = canvas.getContext('2d');
            const testRenderer = new GameRenderer(ctx);
            test('GameRenderer 实例化', typeof testRenderer.renderSimpleGrass === 'function');
        } catch (e) {
            test('GameRenderer 实例化', false);
            console.error('GameRenderer error:', e);
        }
        
        test('CollisionSystem 方法', typeof CollisionSystem.checkCollision === 'function');
        
        // 测试AI系统
        try {
            const mockTank = { position: new Vector2D(100, 100) };
            const testAI = new TankAI(mockTank, 'normal');
            test('TankAI 实例化', testAI.difficulty === 'normal');
        } catch (e) {
            test('TankAI 实例化', false);
            console.error('TankAI error:', e);
        }
        
        try {
            const pathFinder = new PathFinder();
            test('PathFinder 实例化', typeof pathFinder.findPath === 'function');
        } catch (e) {
            test('PathFinder 实例化', false);
            console.error('PathFinder error:', e);
        }
        
        test('ShootingPredictor 静态方法', typeof ShootingPredictor.predictTargetPosition === 'function');
        test('TacticalAnalyzer 静态方法', typeof TacticalAnalyzer.analyzePlayerBehavior === 'function');
        
        console.log('模块测试完成 - 包含高智能AI系统');
    </script>
</body>
</html> 